@extends('web.frame_layout')
<link rel="stylesheet" href="{{asset('web/css/vip-transfer.css')}}">
<?php $parent_menu = "财务中心"; $menu_selected = "币种转换";?>
@section('content')
    <div class="m-right-nr">
        <div>
            <h2><span>{{$menu_selected}}</span></h2>
            <div class="m-vip_trf">
                <form class="bz_zh" id="bz_zh" method="post" action="{{ route('web.switch.coin-act') }}"
                      autocomplete="on">
                    <input name="_token" value="{{csrf_token()}}" type="hidden"/>
                    <ul>
                        <li>
                            <label for="real_coin" class="hidden-xs"><i>*</i>选择原币种：</label>
                            <select id="real_coin" name="real_coin">
                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_1}}">
                                    {{uWalletStr(1)}}（{{ $wallet->w1 }}）
                                </option>
                            </select>
                            <p class="u-ts"></p>
                        </li>
                        <li>
                            <label for="money" class="hidden-xs"><i>*</i>转换金额：</label>
                            <input type="text" id="money" name="money" placeholder="请输入转换金额">
                            <p class="u-ts"></p>
                        </li>
                        <li>
                            <label for="final_coin" class="hidden-xs"><i>*</i>选择目标币种：</label>
                            <select id="final_coin" name="final_coin">
                                <option value="{{\App\Models\MWallet::$WALLET_TYPE_2}}">
                                    {{uWalletStr(2)}}（{{ $wallet->w2 }}）
                                </option>
                            </select>
                            <p class="u-ts"></p>
                        </li>
                        <li>
                            <label for="safepass" class="hidden-xs"><i>*</i>交易密码：</label>
                            <input type="password" id="safepass" name="safepass" placeholder="请输入交易密码">
                            <p class="u-ts"></p>
                        </li>
                        <li>
                            <button>立即转换</button>
                        </li>
                    </ul>
                </form>
            </div>
        </div>
    </div>
@endsection

@section('footer')
    <script type="text/javascript">
        $('#bz_zh').validate({
            rules: {
                safepass: {  //开户人
                    required: true,
                    password: true
                },
                money: {   //开户银行
                    required: true,
                    number: true
                }

            },
            messages: {},
            errorPlacement: function (error, element) {
                $(element).siblings('.u-ts').html(error)
            },
            errorElement: 'span',
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    beforeSend: function () {
                        //禁用按钮,防止重复提交
                        $("button").attr('disabled', 'disabled')
                    },
                    success: function (data) {

                        if (data.code == 0) {
                            toastr["success"](data.msg);
                            setInterval(function () {
                                window.location = "{{route('web.switch.log')}}";
                            }, 2000)
                        } else {
                            $("button").removeAttr('disabled');
                            toastr["error"](data.msg);
                        }
                    }
                });
            }
        });


    </script>
@endsection